Load Script
The Load Script command loads a compiled script into the current script as a script object. A script object is a user-defined object that is treated as a value
by AppleScript. Script objects are described in Chapter 9, "Script Objects,"
of the AppleScript Language Guide.Load Script is the only command provided by the Load Script scripting addition.
SYNTAX
load script referenceToFilePARAMETER
- referenceToFile
- A reference of the form
file nameString
oralias
nameString (see "Notes"). The file must be a compiled script file or a script application file. It cannot be a text file.
Class: ReferenceRESULT
A script object.EXAMPLES
The following example loads a compiled script called Numeric Operations and stores the resulting script object in the variableNumericLib
. The Tell statement shows how to call a subroutine contained in the script object.
load script file "MacHD:Scripts:Numeric Operations"set NumericLib to result tell NumericLib factorial(10) end tellNOTES
To specify the name (nameString) of a file, use a string of the form"Disk:Folder1:
as described in Chapter 5, "Objects and References,"
Folder2:...:Filename"
of the AppleScript Language Guide. If you specify only the name of the file (Filename) instead of its entire pathname, AppleScript attempts to find the file in the current directory.For more information about using Load Script to save and load libraries of subroutines for use in multiple scripts, see Chapter 8, "Handlers," of the AppleScript Language Guide.
ERRORS